package cn.wolfcode.luowowo.mgrsite.controller;

import cn.wolfcode.luowowo.article.domain.DestinationCommendTheme;
import cn.wolfcode.luowowo.article.query.DestinationCommendThemeQuery;
import cn.wolfcode.luowowo.article.service.IDestinationCommendThemeService;
import cn.wolfcode.luowowo.common.util.AjaxResult;
import com.alibaba.dubbo.config.annotation.Reference;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("destinationCommendTheme")
public class DestinationCommendThemeController {

    @Reference
    private IDestinationCommendThemeService destinationCommendThemeService;

    @RequestMapping("/list")
    public String list(Model model, @ModelAttribute("qo")DestinationCommendThemeQuery qo){
        model.addAttribute("pageInfo", destinationCommendThemeService.query(qo));
        return "destinationCommendTheme/list";
    }

    @RequestMapping("/saveOrUpdate")
    @ResponseBody
    public Object saveOrUpdate(DestinationCommendTheme commendTheme) {
        destinationCommendThemeService.saveOrUpdate(commendTheme);
        return AjaxResult.SUCCESS;
    }

    @RequestMapping("/delete")
    @ResponseBody
    public Object delete(Long id) {
        destinationCommendThemeService.delete(id);
        return AjaxResult.SUCCESS;
    }

    @RequestMapping("getThemeByType")
    @ResponseBody
    public List<DestinationCommendTheme> getThemeByType(int type){
        List<DestinationCommendTheme> list = destinationCommendThemeService.getThemeByType(type);
        return list;
    }
}
